package com.breaktian.usercenter.ui;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.breaktian.assemble.utils.LogUtil;
import com.breaktian.assemble.utils.ToastUtil;
import com.breaktian.shell.moduleservice.core.ModuleServicer;
import com.breaktian.shell.moduleservice.stub.LoginServiceStub;
import com.breaktian.usercenter.BuildConfig;
import com.breaktian.usercenter.R;
import com.breaktian.shell.moduleservice.stub.ToastService;

public class UserCenterActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_center);
        LogUtil.i("UserCenterActivity onCreate...");
        boolean isApp = BuildConfig.IS_APPLICATION;
        LogUtil.i("isApp:"+isApp);

        ModuleServicer.getDefault().create(ToastService.class).toast(this,"你好 ModuleService");

        findViewById(R.id.btn_login).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                clickLogin(view);
            }
        });

    }

    private void clickLogin(View view){
        ModuleServicer.getDefault().create(LoginServiceStub.class).login("breaktian", "123456", new LoginServiceStub.LoginCallback() {
            @Override
            public void onSuccess(LoginServiceStub.LoginData data) {
                ToastUtil.show(data.result);
            }

            @Override
            public void onFail(int code, String msg) {
                ToastUtil.show(msg);
            }
        });


    }
}
